package com.cy.pj.module.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
public class ModuleController {

    @RequestMapping("doHandleRequest/{n1}/{n2}")
    @ResponseBody
    public String doHandleRequest(@PathVariable Integer n1,@PathVariable Integer n2){
//        try {
//
            return "n2/n1="+n2/n1;
//        }catch (java.lang.ArithmeticException e){
//            e.printStackTrace();
//            //log.info("exception {}",e.getMessage());
//            return "除数不能为0";
//        }
    }

    @ExceptionHandler(ArithmeticException.class)
    @ResponseBody
    public String doHandleArithmeticException(ArithmeticException e){
        e.printStackTrace();
        return "计算异常："+e.getMessage();
    }
}
